#!/bin/bash


# # 检查输入参数个数
# if [ "$#" -ne 2 ]; then
#     echo "Usage: $0 <source_folder> <destination_file>"
#     exit 1
# fi
#  echo "1"
# 获取输入参数
# SOURCE_FOLDER=$1
# DESTINATION_FILE=$2

current_path=$PWD
APPID=$(grep 'VUE_APP_ID' .env | cut -d '=' -f2)
SOURCE_FOLDER="./dist/$APPID"
DESTINATION_FILE="./dist/temp_$APPID.tar.gz"
echo $SOURCE_FOLDER

 
# 检查源文件夹是否存在
if [ ! -d "$SOURCE_FOLDER" ]; then
    echo "Error: Source folder does not exist."
    exit 1
fi
 
# 压缩文件夹
tar -czf $DESTINATION_FILE -C $(dirname $SOURCE_FOLDER) $(basename $SOURCE_FOLDER)
 
echo "Folder '$SOURCE_FOLDER' has been packaged as '$DESTINATION_FILE'."


curl -i -X POST -H "Content-Type: multipart/form-data" -F "file=@$DESTINATION_FILE" -F "appID=$APPID" http://localhost:8080/uploadSourcemap